from Page.page_csh import Page1
from ddt import ddt,file_data
from selenium import webdriver
from selenium.webdriver.common.by import By
import unittest,time
@ddt()
class TestCase(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
    def tearDown(self):
        self.driver.quit()
    @file_data(r'D:\1\PythonProject4\Data\data.yaml')
    def test_customer_01(self,name,gsname,contact,email,phone,casename,expected):
        print(f'{casename}--------{expected}')

        po = Page1(self.driver)
        po.open_url('http://localhost:8080')
        self.driver.implicitly_wait(10)
        po.login()
        po.username()
        po.password()
        po.loginbtn()
        po.sure()
        time.sleep(2)
        po.accept()
        time.sleep(2)
        dy1 = self.driver.find_element(By.XPATH, '/html/body/div[1]/div/section/section/main/div[2]/span[1]').text
        print(dy1)
        dytext1 = dy1.split(' ')[1]
        print(dytext1)
        po.add()
        po.name(name)
        po.gsname(gsname)
        po.contact(contact)
        po.email(email)
        po.phone(phone)
        po.queren()
        time.sleep(3)
        #断言总条数加1
        dy = self.driver.find_element(By.XPATH,'/html/body/div[1]/div/section/section/main/div[2]/span[1]').text
        print(dy)
        dytext = dy.split(' ')[1]
        print(dytext)
        self.assertEqual((int(dytext1)+1),int(dytext))



if __name__ == '__main__':
    unittest.main()